package com.pi.reservaCita2.client;

import java.util.ArrayList;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.TabLayoutPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class CitasView extends TabLayoutPanel{

	
	public CitasView(double barHeight, Unit barUnit) {
		super(barHeight, barUnit);
		// TODO Auto-generated constructor stub
	}
	//public void CitaView(){}
	public void DrawTable(ArrayList<String[]> datos)
	{
		this.getElement().getStyle().setMarginBottom(10.0, Unit.PX);
		this.setWidth("450px");
        this.setHeight("350px");
       // this.setAnimationDuration(1000);
		/*
	*				idHOrario| |idagenda| |idconsultorio| |nombreConsultorio               |
	*	modelo = :      |2173|;|     182|;|           13|;|"Consultorio 1MEDICINA NUCLEAR "|;|8|;|0|;|2012|;|1|;|22|
	*
	*
	*/
        String ini="";
        String consultorio="";
        Integer count = 0;
        Integer countconsult=0;
        System.out.println(datos.size());
        ArrayList<ArrayList<VerticalPanel> > panels=new ArrayList<ArrayList<VerticalPanel>>();
        
        if(datos.size()!=0){
        	ini=datos.get(0)[datos.get(0).length-1];//dia
        	System.out.println(ini);
        	consultorio=datos.get(0)[3];//idconsultorio
        	panels.add(new ArrayList<VerticalPanel>());
        	panels.get(countconsult).add(new VerticalPanel());
            this.add(panels.get(countconsult).get(count),consultorio);
        	System.out.println("pasee");
        	for(String [] str : datos)
		    {
			System.out.println(consultorio);
			if(consultorio==str[3]){
			//VerticalPanel modpanel= new VerticalPanel();
			//String dia= str[str.length-1];
			if(ini== str[str.length-1])//por dia 
			{
				panels.get(countconsult).get(count).add(new citaButton("ObtenerCita"));
				
			}else
			{	count++;
				//panels.get(countconsult).get(count)=new VerticalPanel();
				panels.get(countconsult).add(new VerticalPanel());
				panels.get(countconsult).get(count).add(new citaButton("ObtenerCIta"));
				ini=str[str.length-1];
			}
			//this.add(modpanel,str[3]);
			}else
			{
				countconsult++;
				count=0;
				consultorio=str[3];
				//panels.get(countconsult)[count]new VerticalPanel();
				panels.add(new ArrayList<VerticalPanel>());
				panels.get(countconsult).add(new VerticalPanel());
				panels.get(countconsult).get(count).add(new citaButton("ObtenerCita"));
				this.add(panels.get(countconsult).get(count),consultorio);
			}
			
		}
		}

        
		}
		
	}
	

